package org.iqiyi.mqHandler;

import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Envelope;
import org.iqiyi.rabbitMq.RabbitMQConfig;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
 * direct 模式就不要指定队列
 * 所以这里面的key可以不指定
 * @describe 这里是采用work 模式
 * 一个生产者对应多个消费者，但是一条消息只能有一个消费者获得消息
 * */
@Component
@RabbitListener(bindings = @QueueBinding(value = @Queue(RabbitMQConfig.QUEUE_NAME),key = RabbitMQConfig.KEY,exchange = @Exchange(value = RabbitMQConfig.EXCHANGE_OPEN)))
public class VideoReceiverHandler {
    @RabbitHandler
    public void process(List<String> params,Channel channel,Message message) throws IOException {
        System.err.println(params);
        // 确定消费
        channel.basicAck(message.getMessageProperties().getDeliveryTag(),true);
        // channel.basicNack(message.getMessageProperties().getDeliveryTag(),false,true);
    }
}
